package org.git.movie.service.impl;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.git.movie.form.VodRecommendForm;
import org.git.movie.mapper.VodRecommendMapper;
import org.git.movie.mapper.ext.VodRecommendExtMapper;
import org.git.movie.service.IVodRecommendService;
import org.git.movie.vo.PageDto;
import org.git.movie.vo.VodRecommendDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author sqyc
 */
@Service
public class VodRecommendServiceImpl implements IVodRecommendService {

    @Autowired
    private VodRecommendExtMapper vodRecommendExtMapper;

    @Autowired
    private VodRecommendMapper vodRecommendMapper;


    @Override
    public PageDto<VodRecommendDto> findPage(VodRecommendForm vodRecommendForm, int pageNo, int pageSize) {
        try{
            PageHelper.startPage(pageNo, pageSize, true);
            List<VodRecommendDto> list = vodRecommendExtMapper.findPage(vodRecommendForm);
            //用PageInfo对结果进行包装
            PageInfo page = new PageInfo(list);
            //自定义转换方法
            return   PageDto.transPageInfo(page);

        }finally {
            PageHelper.clearPage();
        }
    }

    @Override
    public VodRecommendDto findById(Integer id) {
        return vodRecommendExtMapper.findById(id);
    }

}
